-- Stores globally the height and width of player
playerW = 50
playerH = 102

-- Stores the location of the player
playerX = 100 -- X on screen
playerY = 100 -- Y on screen

jumpingState = false

-- Some initilazation
function loadPlayer()
	playerX = 100
	playerY = 100

	-- Graphic for the player standing still
	player = love.graphics.newImage("Content/player/holding.png")
	stillAnim = newAnimation(player, playerW, playerH, 0.25, 1)
	
	bodies[1] = love.physics.newBody(world, playerX+(playerW/2), playerY+(playerH/2), 80, 0)
	shapes[1] = love.physics.newRectangleShape(bodies[1], 0, 0, playerW, playerH, 0)
	shapes[1]:setFriction(0.1)
end

-- Update stuff
function updatePlayer(dt)
	playerX = bodies[1]:getX()
	playerY = bodies[1]:getY()
	
	if love.keyboard.isDown( "up" ) and jumpingState == false then
		jumpingState = false
		bodies[1]:applyImpulse(0, -50)
	end
	
	--x, y = bodies[1]:getLinearVelocity()
	--if y >= -10 and y <= 10 and jumpingState == true then
	--	jumpingState = false
	--end
end

-- Draw player
function drawPlayer()
	-- Draw his collision area for visual feedback
	--playerC:draw('fill')
	-- Draw the standing still animation.
	stillAnim:draw(playerX-(playerW/2), playerY-(playerH/2))
end
